<template>
  <div>
    <el-dialog
      v-model="dialogVisible"
      :title="title"
      width="800px"
      @closed="close"
      @open="openfn"
    >
      <zform
        ref="formz"
        colspan="12"
        label-position="left"
        labelwidth="100px"
        :nowdata="formdata"
        :nowinputs="inputs"
      />
      <ztable ref="tablez" :datas="detaileddata" :tablecolumn="tablecolumn" />

      <div>
        <div></div>
      </div>
      <template #footer>
        <slot name="btnslot"></slot>
        <el-button @click="close">关闭</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script>
  import zform from '@/components/zFrom/zFrom'
  import ztable from '@/components/zTable/index'
  export default {
    name: 'afterlistxjpd',
    components: {
      zform,
      ztable,
    },
    data() {
      return {
        dialogVisible: false,
        title: '设备详情',
        formdata: {},
        loading: false,
        inputs: [
          { label: 'ID', value: 'gtel', readonly: true },
          { label: '站点', value: 'pcsxs', readonly: true },
        ],
        detaileddata: [],
        tablecolumn: [
          { label: '序号', value: 'index' },
          { label: '日期', value: 'sjc' },
          // { label: '维修人', value: 'pcsxs' },
          {
            label: '故障代码',
            value: 'type',
            type: 'select',
            option: [
              { label: '3天内无人用', value: '0' },
              { label: '3次故障', value: '1' },
              { label: '离线', value: '2' },
              { label: '继电器吸合', value: '2' },
            ],
          },
          { label: '维修情况', value: 'wxms' },
        ],
      }
    },
    mounted() {},
    methods: {
      close() {
        this.dialogVisible = false
      },
      openfn() {},
      async show(gteldata) {
        let station = this.$store.state.station.Station.find(function (f) {
          return f.id == gteldata.pcs
        })
        this.formdata = { ...gteldata, pcsxs: station ? station.pcs : '' }
        let { data } = await this.$z.$axios.post('/AfterListDetailed', {
          gtel: this.formdata.gtel,
          sjc: this.formdata.sjc,
        })

        this.detaileddata = data.map((e, i) => {
          let num = Number(i) + 1
          return { ...e, index: num }
        })
        this.dialogVisible = true
      },
      async updatafn() {
        if (this.USearchactive == '') {
          this.$message.error('请选择用户')
          return
        }
        let reqs = []
        this.formdata.gtels.forEach((e) => {
          reqs.push(
            this.$z.$axios.post('/AfterListedt', {
              ...e,
              uUser: this.USearchactive,
            })
          )
        })
        await Promise.all(reqs)
        this.$message.success('操作完成')
        this.loading = false
        this.dialogVisible = false
        this.asynccallback()
      },
    },
  }
</script>
<style lang="scss">
  .USearchbox {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    display: flex;
  }
</style>
